﻿using PhotoBook.Repositorio;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PhotoBook.Model.Entities;
using System.Collections.Generic;

namespace PhotoBook.Test
{
    
    
    /// <summary>
    ///This is a test class for RepositorioCategoriaTest and is intended
    ///to contain all RepositorioCategoriaTest Unit Tests
    ///</summary>
    [TestClass()]
    public class Testa_Repositorio_De_Categoria : TestBase
    {
    
        /// <summary>
        ///A test for Update
        ///</summary>
        [TestMethod()]
        public void UpdateTest()
        {
            RepositorioCategoria target = new RepositorioCategoria();
            Categoria obj = new Categoria() { IdCategoria=0, Descricao="Test" };
            target.Insert(obj);
            //obj.IdCategoria = 0;
            obj.Descricao = "ValueModified";
            target.Update(obj);
            var objReturn = target.SelectById(obj.IdCategoria);
            Assert.AreEqual(obj.Descricao, objReturn.Descricao);
        }

        /// <summary>
        ///A test for SelectById
        ///</summary>
        [TestMethod()]
        public void SelectByIdTest()
        {
            RepositorioCategoria target = new RepositorioCategoria();
            Categoria obj = new Categoria() { IdCategoria = 0, Descricao = "Test" };
            target.Insert(obj);
            var objReturn = target.SelectById(obj.IdCategoria);
            Assert.AreEqual(obj.Descricao, objReturn.Descricao);          
        }

        /// <summary>
        ///A test for Select
        ///</summary>
        [TestMethod()]
        public void SelectTest()
        {
            RepositorioCategoria target = new RepositorioCategoria(); 
            IList<Categoria> expected = new List<Categoria>() { new Categoria(){ IdCategoria=0, Descricao="Teste" }}; 
            IList<Categoria> actual;
            Categoria obj = new Categoria() { IdCategoria = 0, Descricao = "Teste" };
            target.Insert(obj);
            actual = target.Select();
            Assert.AreEqual(expected.Count, actual.Count);
            Assert.AreEqual(expected[0].Descricao, actual[0].Descricao);
        }

        /// <summary>
        ///A test for Insert
        ///</summary>
        [TestMethod()]
        public void InsertTest()
        {
            RepositorioCategoria target = new RepositorioCategoria();
            Categoria obj = new Categoria() {  IdCategoria=0, Descricao="Description" };             
            target.Insert(obj);
            Assert.AreNotEqual(obj.IdCategoria, 0);            
        }     
    }
}
